<template>
	<view>
		<view class="fenlei">
			<view class="toubus" v-if="types == 2">
				<scroll-view class="scroll-view_H2" scroll-x="true">

					<view class="scroll-view_H_tops2 " :class="index == ind?'active':''" @tap="set(ind,val.id)" v-for='(val,ind) in uy'>{{val.name}}
						<span></span></view>

				</scroll-view>
			</view>
			<view class="lists acea-row row-between-wrapper" v-for='val in list' @click="urlSet(val.post_url,val.status,val.id)">
				<view class="zhangtai  acea-row row-center-wrapper" v-if='val.status == 1' :class="val.status == 0?'backcolor1':'backcolor2'" >
					<span></span>
					<view>{{val.icon}}</view>
				</view>
				<view class="zhangtai  acea-row row-center-wrapper" v-if='val.status == 0' :class="val.status == 0?'backcolor1':'backcolor2'" >
					<span></span>
					<view>{{val.icon}}</view>
				</view>
				<image :src="val.thumbnail" mode="aspectFill"></image>
				<view class="rits">
					<view class="title textline">{{val.post_title}}</view>
					<view class="acea-row Jud">
						<view class="jiangjie">主讲：{{val.post_ren}}</view>
						<view class="zhuanyei">{{val.post_yy}}</view>
					</view>
					<view class="acea-row row-between-wrapper botts">
						<view class="acea-row ">
							<image src="../../static/z.png"></image>
							<view class="time">{{val.post_times}}</view>
						</view>
						<view v-if="types == 1" :class="val.status == 0?'yuyues' :val.status==1 ?'biaoqian':'biaoqian' ">
							{{val.button}}
						</view>
						<view v-if="types == 2" class="biaoqian ">
							{{val.button}}
						</view>
					</view>
				</view>
			</view>


		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				index: 0,
				page: 1,
				limit: 100,
				uy: [],
				list: [],
				types:null
			}
		},
		onLoad(e) {
			var that = this
			console.log(e)
			this.types = e.type
			this.$api('/portal/index/zhibo', {
				datas: {
					page: that.page,
					limit: that.limit,
					type:e.type
				}
			}, function(res) {
				console.log(res)
				that.uy = res.data.data.cate
				that.list = res.data.data.list
			})
			var jweixin = require('jweixin-module')
			var that = this
			console.log(jweixin)
				var urls = window.location.href
			this.$api('/portal/index/jsconfig', {datas:{url:urls}}, function(res) {
				console.log(res)
				var s = res.data.data
				jweixin.config({
				    debug: false,
				    appId: s.appId,
				    timestamp: s.timestamp,
				    nonceStr: s.nonceStr,
				    signature:s.signature,
				    jsApiList: ["updateTimelineShareData","updateAppMessageShareData"]
				});
				jweixin.ready(function(){
				jweixin.updateTimelineShareData({
						title: '海绵医学院', // 分享标题
					    link: urls, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
					    imgUrl: 'http://api.haimiantv.cn/upload/default/20200426/86ea4921376b6656f24fbb40e674b361.png', // 分享图标
					    success: function () {
					      // 设置成功
						  console.log(1)

					    }
				})
				jweixin.updateAppMessageShareData({
					title: '海绵医学院', // 分享标题
					desc: '一个专业/有态度的医学直播交流平台', // 分享描述
					link: urls, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
					imgUrl: 'http://api.haimiantv.cn/upload/default/20200426/86ea4921376b6656f24fbb40e674b361.png', // 分享图标
					success: function () {
					  // 设置成功
					}
				  })



				})
				jweixin.error(function(res){
					console.log(res)
				})
			})
		},
		methods: {
			urlSet(e,type,id){
				console.log(type)
				var url = e
				var that = this

				if(type == 0){
					// 可预约
					console.log(id)
					var ids = uni.getStorageSync('ids')
					this.$api('/portal/index/yy',{datas:{id:id,user_id:ids}},function(res){
						console.log(res)
						var icon
						if(res.data.code == 200){
							icon = 'success'
						}else{
							icon = 'none'
						}
						uni.showToast({
							title:res.data.msg,
							icon:icon,
							duration:1500
						})
					})
				}else{
					console.log(url)
					if(url == ''|| url == undefined){
						return false
					}
					window.location.href = url
				/* 	uni.navigateTo({
						url:'../webView/webView?url='+url
					}) */
				}
			},
			set(e,id) {
				this.index = e
				var that = this
				this.$api('/portal/index/zhibo', {
					datas: {
						cid:id,
						page: that.page,
						type:that.types,
						limit: that.limit
					}
				}, function(res) {
					console.log(res)
					if( res.data.data.list.length == 0){
						uni.showToast({
							title:'什么都没有~',
							icon:'none',
							duration:1500
						})
					}
					that.list = res.data.data.list
				})
			}
		}
	}
</script>

<style>
	.yuyues{
		padding: 8rpx 20rpx;
		color: #fff;
		font-size: 28rpx;
		background:linear-gradient(90deg,rgba(22,137,244,1),rgba(38,200,202,1));
		border-radius:22rpx;
	}
	.fenlei {
		margin-top: 20rpx;
	}

	.scroll-view_H2 {
		width: 100%;
		height: 80rpx;
		white-space: nowrap;
		overflow: hidden;
		padding-left: 26rpx;
		box-sizing: border-box;
	}

	.scroll-view_H_tops2 {
		display: inline-block;
		color: #999999;
		font-size: 30rpx;
		margin-right: 50rpx;
	}

	.scroll-view_H2 .active {
		position: relative;
		font-weight: bold;
		font-size: 32rpx;
		color: #000000;
	}

	.scroll-view_H2 .active span {
		position: absolute;
		left: 50%;
		bottom: -25rpx;
		width: 36rpx;
		height: 6rpx;
		border-radius: 3rpx;
		background: linear-gradient(69deg, rgba(60, 175, 255, 1), rgba(74, 242, 220, 1));
		margin-left: -18rpx;
	}

	.zhangtai {
		background-color: rgba(0, 0, 0, .6);
		width: 152rpx;
		height: 54rpx;
		position: absolute;
		top: 0;
		left: 0;
		z-index: 9999;
		color: #fff;
		font-size: 26rpx;
		border-radius: 20rpx 0 50rpx 0;
	}

	.zhangtai span {
		border-radius: 50%;
		margin-right: 15rpx;
		display: block;
		width: 10rpx;
		height: 10rpx;
	}

	.backcolor1 span {
		background-color: #FFBD40;
	}

	.backcolor2 span {
		background-color: #5DE23F;
	}

	.lists {


		width: 697rpx;

		position: relative;
		margin: 0 auto;
		margin-top: 26rpx;
	}

	.lists image {
		width: 280rpx;
		height: 154rpx;
		border-radius: 15rpx;
	}

	.lists .rits {
		width: 390rpx;
	}

	.rits .title {
		font-size: 28rpx;
		color: #000000;
		font-weight: bold;
	}

	.lists .jiangjie {
		color: #666666;
		font-size: 20rpx;
		margin-right: 10rpx;
	}

	.lists .zhuanyei {
		font-size: 16rpx !important;
		border: 1px solid #FFA708;
		color: #FFA708;
		padding: 3rpx 10rpx;
		border-radius: 30rpx;
	}

	.Jud {
		margin-top: 20rpx;
	}

	.botts {
		margin-top: 20rpx;
	}

	.botts image {
		width: 23rpx;
		height: 23rpx;
		margin-right: 15rpx;
	}

	.botts .acea-row {
		align-items: center;
		font-size: 20rpx !important;
		color: #40A3FC;
	}

	.biaoqian {
		color: #53B655;
		font-size: 22rpx !important;
		padding: 5rpx 10rpx;
		background-color: #F2F3F3;
		border-radius: 25rpx;
	}

	.genduos {
		color: #BBBABA;
		font-size: 24rpx;
		height: 120rpx;

	}

	.genduos image {
		width: 11rpx;
		height: 17rpx;
		margin-left: 10rpx;
	}

	.index_tuijian {}

	.order_img image {
		width: 698rpx;
		height: 500rpx;
		margin: 0 auto;
		margin-bottom: 32rpx;

	}
</style>
